package com.bdqn.day0104.controller;

import com.bdqn.day0104.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author:Corday
 * @Date:2022/01/04/10:46
 */
@Controller
public class MyController {
    @RequestMapping("/go1")// http://localhost:8080/go1
    //1.使用传值的对象Map,Model,HttpSession等
    public String goOne(Map map) {
        map.put("msg","万紫千红总是春");
        User user = new User(301,"李明","男");
        map.put("user",user);
        //传一个图片文件名到前端，动态渲染
        map.put("emo3","emo3");
        //传递一个网页路径给前端
        map.put("badidu","http://www.baidu.com");
        map.put("myurl","play");
        return "page/index";
    }
    //2.thymeleaf的迭代数据
    @RequestMapping("/go2")// http://localhost:8080/go2
    public String go2(Map map){
        List<User> list = new ArrayList<>();
        list.add(new User(301,"李明","男"));
        list.add(new User(302,"胡月","女"));
        list.add(new User(303,"王五","男"));
        list.add(new User(304,"张帅","男"));
        list.add(new User(305,"高明","女"));
        map.put("users",list);
        User us=new User(308,"李美丽","女");
        map.put("us",us);
        return "page/home";
    }
}
